<!doctype html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link href="../css/goods_add.css" rel="stylesheet" />
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">发布宝贝</h1>
		</header>
		<div class="mui-content">
			<form class="mui-input-group">
				<!--<div class="mui-input-row">
					<label>标题</label>
					<input type="text" id="title" placeholder="请输入标题">
				</div>-->
				<div class="mui-input-row">
					<label>宝贝类型</label>
					<select id="goodsType">
						<option value="手机数码" selected="">手机数码</option>
						<option value="女装">女装</option>
						<option value="男装服饰">男装服饰</option>
						<option value="书刊">电器</option>
						<option value="其他">其他</option>
					</select>
				</div>
				<div class="mui-input-row">
					<label>所属校区</label>
					<select id="campus">
						<option value="雅安校区" selected="">雅安校区</option>
						<option value="雅安校区">成都校区</option>
						<option value="雅安校区">都江堰校区</option>
					</select>
				</div>
				<!--<div class="mui-input-row">
					<label>联系电话</label>
					<input type="text" id="phone" placeholder="请输入手机号">
				</div>-->
				<div class="mui-input-row">
					<label>价格</label>
					<input type="text" id="price" placeholder="请输入售价">
				</div>
				
				<div class="mui-input-row">
					<label>原始价格</label>
					<input type="text" id="originalPrice" placeholder="请输入商品原价">
				</div>
				<div class="mui-input-row">
					<label>邮费</label>
					<input type="text" id="postage" placeholder="请输入邮费">
				</div>
				<textarea placeholder="宝贝描述" id="des" style="height: 80px;"></textarea>

			</form>
			<div id="pic_list">
				<div class="picBox">
					<img id="headimg0" src="../images/camera.jpg">
				</div>

			</div>
			<div style="margin-top:20px;text-align: center;">
				<button class="mui-btn mui-btn-primary" id="pubGoods">立即发布</button>

			</div>
		</div>

		<script src="../js/mui.min.js"></script>
		<script src="../js/const.js"></script>
		<script type="text/javascript" src="../js/upload.js"></script>
		
		<script type="text/javascript" src="../js/request.js"></script>
		<script type="text/javascript" src="../js/goods_service.js"></script>
		<script type="text/javascript">
			mui.init()
				(function($, doc) {
					$.plusReady(function() {
						var pubGoodsButton = doc.getElementById('pubGoods');
						pubGoodsButton.addEventListener('tap', function(event) {
							var goods = new Object();
//							goods.title = document.getElementById('title').value;
							goods.des = document.getElementById('des').value;
//							goods.phone = document.getElementById('phone').value;
							goods.price = document.getElementById('price').value;
							goods.originalPrice = document.getElementById('originalPrice').value;
							goods.goodsType = document.getElementById('goodsType').value;
							goods.campus = document.getElementById('campus').value;
							goods.postage = document.getElementById('postage').value;
//							
							
							if(picArrary==null || picArrary.length==0){
								plus.nativeUI.toast("你还未添加宝贝照片");
								return;
							}
							goods.picArrary = picArrary.toString();
							
							console.log(JSON.stringify(goods));
							var wt = plus.nativeUI.showWaiting("正在发布...");
							
							var res = goodsService.create_goods(goods);
							if(res.resultCode === REQUEST_SUCCESS_CDOE) {
								wt.close();
								plus.nativeUI.toast(res.msg);
								setInterval(function() {
									mui.currentWebview.close();
								}, 2000);

							} else {
//								console.log("sfds");
								wt.close();
								plus.nativeUI.toast(res.msg);
							}
						});

					});
				}(mui, document));
		</script>
	</body>

</html>